package cn.wyu.service;

import cn.wyu.dao.ShopCarDao;
import cn.wyu.dao.ShopCarDaoImpl;
import cn.wyu.pojo.Information;

import java.util.List;

public class ShopCarServiceImpl implements ShopCarService {
    private ShopCarDao dao = new ShopCarDaoImpl();

    @Override
    public List<Information> findAll() {
        //调用Dao完成查询
        return dao.findAll();
    }
    @Override
    public List<Information> findAllOrderForm() {
        //调用Dao完成查询
        return dao.findAllOrderForm();
    }

    //加入购物车
    @Override
    public void addOrderForm(Information information) {
        dao.addOrderForm(information);
    }

    //提交订单
    @Override
    public void addInformation(Information information) {
        dao.add(information);
    }

    @Override
    public void deleteInformation(String id) {
        dao.delete(Integer.parseInt(id));
    }

    @Override
    public Information findInformationById(String id) {
        return dao.findById(Integer.parseInt(id));
    }

    @Override
    public void updateInformation(Information information) {
        dao.update(information);
    }

    @Override
    public void delSelectedUser(String[] ids) {
        if(ids != null && ids.length > 0){
            //1.遍历数组
            for (String id : ids) {
                //2.调用dao删除
                dao.delete(Integer.parseInt(id));
            }
        }

    }


}
